// ==================================================================================
// Shared Genomics Project MPI Codebase
// Version 1.0 30/04/2010
//
// (c) 2010 University of Manchester all rights reserved
//
// This file is distributed under the GNU General Public License, Version 2.  
// Please see the file COPYING.txt for more details
// ==================================================================================

#ifndef _PHEFILE_H_
#define _PHEFILE_H_

#include "options.h"
#include "pedfile.h"

#ifdef __cplusplus
extern "C" {
#endif

/*!
\file
\ingroup	gio
\brief		Phenotype Utility Functions (Text File)
\details	
	Read a phenotype column from a PLINK compatible text file.<br>
	Methods largely superfluous as largely been replaced by the functions of \ref sample.h .<br>
	Mainly used now in the older test of unit testing code.
\deprecated Unit Test methods only.
*/

/*!
\brief Read a column from a PLINK phenotype file.
\details
	The input file path is bound to \ref selected_options::szPheFileName.<br>
	The PLINK phenotype index (1..n) is bound to \ref selected_options::mpheno.<br>
	The phenotype data is bound to \ref pedfile::sample array of the pedfile parameter.
\param [in,out] ped pedfile parameter
\param [in] ops Input file location and PHE column index
\return 1 on success, 0 on failure
*/
int phefile_read(struct pedfile *ped, struct selected_options *ops);

/*!
\brief For a binary trait, apply affected status to a \ref pedfile sample array.
\param [in,out] ped pedfile parameter
\return 1 on success, 0 on failure
*/
int phefile_aff_coding(struct pedfile *ped);

/*!
\brief Load a column from a PLINK phenotype file and fill an array with missing values.
\details
	The input file path is bound to \ref selected_options::szPheFileName.<br>
	The elements of the phe_missing array are initialised to FALSE.<br>
\param [in] ops Input file location and PHE column index
\param [in] nSamples Size of the phe_missing array
\param [in] phe_missing Missing-phenotype status array
\return double array cotaining the phenotype data or NULL on failure
*/
double* phefile_load(struct selected_options *ops, int nSamples, BOOL *phe_missing);

#ifdef __cplusplus
}
#endif

#endif // _PHEFILE_H_
